Skip to content

fix(backend/frontend): gzip middleware + StreamDetailDrawer Stellar Expert tx links#619

Merged
ritik4ever merged 1 commit into
ritik4ever:mainfrom
ogazboiz:fix/364-399-gzip-txhash-links
Jun 29, 2026
Merged

fix(backend/frontend): gzip middleware + StreamDetailDrawer Stellar Expert tx links#619
ritik4ever merged 1 commit into
ritik4ever:mainfrom
ogazboiz:fix/364-399-gzip-txhash-links

Conversation

@ogazboiz

@ogazboiz ogazboiz commented Jun 27, 2026

Copy link
Copy Markdown
Contributor

Closes #364
Closes #399
Closes #359
Closes #352

Summary

#364 — Gzip compression middleware

compression({ threshold: 1024 }) is already registered as early middleware in backend/src/index.ts (before all route handlers), compressing all responses above 1 KB. No further changes needed — this issue is resolved.

#399 — StreamDetailDrawer Stellar Expert transaction links

  • Added TxHashLink component to StreamDetailDrawer.tsx: renders any txHash as a clickable <a> to https://stellar.expert/explorer/testnet/tx/<hash>, opens in a new tab with rel="noopener noreferrer", truncates display to first 8 + last 8 chars, full hash in title tooltip
  • Added txHash?: string field to StreamEvent interface in services/api.ts
  • Wired TxHashLink into the event history list — renders only when txHash is present
  • Updated MSW mock handler with a txHash on the claimed event for test coverage
  • 5 new Vitest tests: correct href, target=_blank, rel, truncated display, absent when no hash — all 34 drawer tests pass

Summary by CodeRabbit

  • New Features

    • Transaction hashes in stream event history now appear as clickable links to the Stellar Expert testnet explorer.
    • Links open in a new tab, show the full hash on hover, and display a shortened hash for easier scanning.
  • Bug Fixes

    • Event history now hides the transaction link when no hash is available, avoiding empty or broken entries.

…Expert tx links

fix(ritik4ever#364): gzip compression via compression({ threshold: 1024 }) is already
applied as early middleware in backend/src/index.ts — confirmed present and
correctly registered before all route handlers

fix(ritik4ever#399): render all txHash values in StreamDetailDrawer event history as
clickable links to https://stellar.expert/explorer/testnet/tx/<hash>
- add TxHashLink component: truncates to first 8 + last 8 chars, full hash
  in title tooltip, opens in new tab with rel=noopener noreferrer
- add txHash field to StreamEvent interface in services/api.ts
- wire TxHashLink into event history list items
- add txHash to MSW mock handler for testing
- 5 new Vitest tests: correct href, target=_blank, rel, truncation, no link
  when txHash absent — all 34 drawer tests pass
@vercel

vercel Bot commented Jun 27, 2026

Copy link
Copy Markdown

@ogazboiz is attempting to deploy a commit to the ritik4ever's projects Team on Vercel.

A member of the Team first needs to authorize it.

@drips-wave

drips-wave Bot commented Jun 27, 2026

Copy link
Copy Markdown

@ogazboiz Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@coderabbitai

coderabbitai Bot commented Jun 27, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Adds a TxHashLink exported component and STELLAR_EXPERT_BASE constant to StreamDetailDrawer.tsx that renders transaction hashes as truncated, accessible links to the Stellar Expert testnet explorer. StreamEvent gains an optional txHash field, the mock handler includes a test hash, and six new Vitest assertions cover all link behaviors.

TxHashLink: Stellar Expert transaction links

Layer / File(s) Summary
StreamEvent type, TxHashLink component, and event history wiring
frontend/src/services/api.ts, frontend/src/components/StreamDetailDrawer.tsx, frontend/src/handlers.ts
StreamEvent gets optional txHash; TxHashLink truncates the hash and links to Stellar Expert with target="_blank", rel, tooltip, and aria-label; event history conditionally renders it; mock handler includes a test hash.
TxHashLink UI tests
frontend/src/components/StreamDetailDrawer.test.tsx
Six assertions cover correct href, new-tab attributes, truncated display, full-hash tooltip, and absence of the link when txHash is missing.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

🐇 A hash in the stream, once lost in the text,
Now hops to the stars — what a delightful effect!
Eight chars at the front, eight chars at the tail,
A link to the cosmos, beyond every veil.
Click! And the explorer opens wide —
This bunny ships features with impeccable pride. 🌟

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Linked Issues check ❓ Inconclusive Issue #399 appears covered, but #364 can't be verified because the diff shows no backend middleware changes. Include the backend diff or evidence that compression middleware is applied before routes and gzips responses over 1KB.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title is concise and matches the main backend/frontend changes, especially gzip and Stellar Expert tx links.
Out of Scope Changes check ✅ Passed The changed files are all related to the tx-link feature and test updates; no unrelated changes are evident.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@frontend/src/components/StreamDetailDrawer.test.tsx`:
- Around line 454-460: The test in StreamDetailDrawer is too broad because it
only checks the total number of “View transaction” links, so it won’t catch a
link appearing on the “Stream created” row. Update the assertion in the test
case for StreamDetailDrawer to scope directly to the “Stream created” list
item/row and verify that specific row has no transaction link, while still
allowing the claimed event to have one. Use the existing StreamDetailDrawer
render and the “Stream created” text to locate the correct row.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: b178ee75-37ca-4a24-b2de-512265e072cf

📥 Commits

Reviewing files that changed from the base of the PR and between 49ecbf8 and a2cd8b8.

📒 Files selected for processing (4)
  • frontend/src/components/StreamDetailDrawer.test.tsx
  • frontend/src/components/StreamDetailDrawer.tsx
  • frontend/src/handlers.ts
  • frontend/src/services/api.ts

Comment on lines +454 to +460
it('does not render a tx link when txHash is absent', async () => {
render(<StreamDetailDrawer streamId="42" onClose={onClose} />);
await waitFor(() => expect(screen.getByText('Stream created')).toBeInTheDocument());
// "created" event has no txHash — only the "claimed" event has a link
const links = screen.queryAllByRole('link', { name: /View transaction/i });
expect(links.length).toBeLessThanOrEqual(1);
});

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Assert against the specific "Stream created" event row.

Line 458 only caps the total number of tx links on the page, so this still passes if the link moves from the claimed event to the created event. Scope the assertion to the "Stream created" list item and verify that row has no transaction link.

Suggested test shape
   it('does not render a tx link when txHash is absent', async () => {
     render(<StreamDetailDrawer streamId="42" onClose={onClose} />);
     await waitFor(() => expect(screen.getByText('Stream created')).toBeInTheDocument());
-    // "created" event has no txHash — only the "claimed" event has a link
-    const links = screen.queryAllByRole('link', { name: /View transaction/i });
-    expect(links.length).toBeLessThanOrEqual(1);
+    const createdRow = screen.getByText('Stream created').closest('li');
+    expect(createdRow).not.toBeNull();
+    expect(
+      within(createdRow as HTMLElement).queryByRole('link', { name: /View transaction/i }),
+    ).not.toBeInTheDocument();
   });
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
it('does not render a tx link when txHash is absent', async () => {
render(<StreamDetailDrawer streamId="42" onClose={onClose} />);
await waitFor(() => expect(screen.getByText('Stream created')).toBeInTheDocument());
// "created" event has no txHash — only the "claimed" event has a link
const links = screen.queryAllByRole('link', { name: /View transaction/i });
expect(links.length).toBeLessThanOrEqual(1);
});
it('does not render a tx link when txHash is absent', async () => {
render(<StreamDetailDrawer streamId="42" onClose={onClose} />);
await waitFor(() => expect(screen.getByText('Stream created')).toBeInTheDocument());
const createdRow = screen.getByText('Stream created').closest('li');
expect(createdRow).not.toBeNull();
expect(
within(createdRow as HTMLElement).queryByRole('link', { name: /View transaction/i }),
).not.toBeInTheDocument();
});
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@frontend/src/components/StreamDetailDrawer.test.tsx` around lines 454 - 460,
The test in StreamDetailDrawer is too broad because it only checks the total
number of “View transaction” links, so it won’t catch a link appearing on the
“Stream created” row. Update the assertion in the test case for
StreamDetailDrawer to scope directly to the “Stream created” list item/row and
verify that specific row has no transaction link, while still allowing the
claimed event to have one. Use the existing StreamDetailDrawer render and the
“Stream created” text to locate the correct row.

@ritik4ever ritik4ever merged commit 85ef4f8 into ritik4ever:main Jun 29, 2026
3 of 6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants